package com.woke.adapter;

import java.util.ArrayList;
import java.util.List;

import com.zhongcai.online.R;
import com.woke.data.Data_zhcailidingqi;
import com.woke.diyview.RoundProgressBar1;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class Dingqilistadter extends BaseAdapter{
	private LayoutInflater mInflater;
	private List<Data_zhcailidingqi> datalist;

	public Dingqilistadter(LayoutInflater minflater, ArrayList<Data_zhcailidingqi> datalist) {
		this.mInflater = minflater;
		this.datalist = datalist;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return datalist.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	class Holder {
		RoundProgressBar1 mBraepr;
		TextView mTdate;
		TextView mTlilv;
		TextView mTmoney;
		TextView mTtitle;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		if(convertView == null){
			holder = new Holder();
			convertView = mInflater.inflate(R.layout.item_zhcailicai_adater, null);
//			holder.mIicon = (ImageView) convertView.findViewById(R.id.item_myblind_bankicon);
			holder.mBraepr = (RoundProgressBar1) convertView.findViewById(R.id.item_zhcailicai_progerss);
			holder.mTdate = (TextView) convertView.findViewById(R.id.item_zhcailicai_textdate);
			holder.mTlilv = (TextView) convertView.findViewById(R.id.item_zhcailicai_textlilv);
			holder.mTmoney = (TextView) convertView.findViewById(R.id.item_zhcailicai_textmoney);
			holder.mTtitle= (TextView) convertView.findViewById(R.id.item_zhcailicai_texttitle);
			convertView.setTag(holder);
		}else{
			 holder = (Holder) convertView.getTag();
		}
		
		Data_zhcailidingqi data = datalist.get(position);
		holder.mTdate.setText(data.date+"天");
		holder.mTlilv.setText(data.interest+"%");
		holder.mTmoney.setText(data.money+"元");
		holder.mTtitle.setText(data.product_name);
		
		float parseFloat = Float.parseFloat(data.exp_money);
		float money = Float.parseFloat(data.money);
		
		if(parseFloat == 0){
			holder.mBraepr.setProgress(100);
		}else{
			int progress = (int) (((money - parseFloat )/ money)*100);
			holder.mBraepr.setProgress(progress);
		}
		
		return convertView;
	}

}
